﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

//using PowerCreator.LMS.Logic.CourseManager;
//using PowerCreator.LMS.Logic.ProjectManager;
//using PowerCreator.LMS.Logic.Common;
//using PowerCreator.LMS.Logic.FusionCharts;

public partial class sysadmin_CountManager_AllCoursePass : PowerCreator.LMS.Web.Base.BasePage
{
    #region XML数据模版 ？为什么不采用模版的方式，新建了FusionCharts类，但是不能用

    //图表抬头 Title, xAxisName=X轴的名称，yAxisName=y轴显示的名称,yAxisMaxValue=y轴最大值
    const string GRAPH = "<graph  caption='全部课程通过率'  xAxisName='通过率值' yAxisName='课程名称列表' decimalPrecision='0' formatNumberScale='0' yAxisMaxValue='100' baseFontSize='14' rotateNames='1' shownames='1'> ";
    //名称，值，颜色
    const string GRAPH_TR = "<set name='{0}' value='{1}' color='{2}' showName='1'/>";
    const string GRAPH_END = "</graph>";
//    const string REPORT_URL = "/FusionCharts/FCF_Column3D.swf";

    //使用另一个
    const string CHART = "<chart caption='全部课程通过率' xAxisName='通过率值' yAxisName='课程名称列表' showValues='0' decimals='0' formatNumberScale='0' yAxisMaxValue='100' baseFontSize='14'>";
    const string CHART_TR = "<set name='{0}' value='{1}'/>";
    const string CHART_END = "</chart>";
    #endregion 
    
    //ManagerCourseInfo courseManager = new ManagerCourseInfo();
    //ManagerProjectSchedule projectScheduleManager = new ManagerProjectSchedule();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //string xml = GetXml();
            //if (!string.IsNullOrEmpty(xml))
            //{
            //    literal1.Text = InfoSoftGlobal.FusionCharts.RenderChartHTML(FCTemplate.GetColumn3D(), "", xml, "myxml", "800", "400", false);
            //}
        }
    }

    private string GetXml()
    {
        StringBuilder sbXML = new StringBuilder();
        //DataTable dt = new DataTable();
        //dt = GetAllCourse();
        //int passv = 0;
        //int maxv = 0;
        //int showv = 0;
        ////sbXML.Append(GRAPH);
        //sbXML.Append(CHART);
        //for (int i = 0; i < dt.Rows.Count; i++)
        //{
        //    passv = GetCoursePass(int.Parse(dt.Rows[i]["CourseID"].ToString()),3);
        //    maxv = GetCourseCount(int.Parse(dt.Rows[i]["CourseID"].ToString()));
        //    if (passv == 0)
        //        showv += 1;
        //    passv = ReportUtils.GetBaiFenBi(passv.ToString(),maxv.ToString());
        //    //sbXML.Append(string.Format(GRAPH_TR, Utils.CutTitle(dt.Rows[i]["CourseName"].ToString(),1), passv, ReportUtils.GetColorRander(6)));
        //    //sbXML.Append(string.Format(GRAPH_TR, dt.Rows[i]["CourseName"], passv, ReportUtils.GetColorRander(6)));
        //    sbXML.Append(string.Format(CHART_TR, dt.Rows[i]["CourseName"], passv));
        //}
        ////sbXML.Append(GRAPH_END);
        //sbXML.Append(CHART_END);
        ////if (showv == dt.Rows.Count)
        ////{
        ////    sbXML.Remove(0,sbXML.Length);
        ////}
        return sbXML.ToString();
    }
    private DataTable GetAllCourse()
    {
        DataTable dt = new DataTable();
        //dt = courseManager.Query("");
        return dt;
    }
    private int GetCourseCount(int courseid)
    {
        string search = string.Format("ProjectResourceID in (select ProjectResourceID from ProjectResource where TypeID=0 and ResourceID={0})", courseid.ToString());
       // return projectScheduleManager.Count(search);
        return 0;
        
    }
    private int GetCoursePass(int courseid,int ispass)
    {
        //string search = string.Format("ProjectResourceID in (select ProjectResourceID from ProjectResource where TypeID=0 and ResourceID={0}) and State={1}", courseid.ToString(), ispass.ToString());
        //return projectScheduleManager.Count(search);
        return 0;
    }
}
